package com.sky.workspace.controller;

import com.sky.result.Result;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import com.sky.workspace.service.WorkSpaceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 工作台 controller
 */
@Slf4j
@Api(tags = {"工作台"}, description = "后台工作台页面")
@RestController
@RequestMapping("/admin/workspace")
public class WorkSpaceController {


    @Resource
    private WorkSpaceService workSpaceService;



    /**
     * 工作台
     *      今日运营数据
     */
    @GetMapping("/businessData")
    @ApiOperation(tags = {"工作台"}, value = "今日运营数据", notes = "今日运营数据查询")
    public Result<BusinessDataVO> businessData(){
        // 今天的 起/始时间
        LocalDateTime startTime = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime endTime = LocalDateTime.now().with(LocalTime.MAX);

        BusinessDataVO businessDataVO = workSpaceService.businessData(startTime, endTime);
        return Result.success(businessDataVO);
    }



    /**
     * 工作台
     *      查询订单管理数据
     */
    @ApiOperation(tags = {"工作台"}, value = "订单管理数据", notes = "查询订单管理数据")
    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> ordersOverView(){
        return Result.success(workSpaceService.getOrderOverView());
    }



    /**
     * 工作台
     *      查询菜品总览
     */
    @ApiOperation(tags = {"工作台"}, value = "菜品总览", notes = "查询菜品总览")
    @GetMapping("/overviewDishes")
    public Result<DishOverViewVO> dishOverView(){
        return Result.success(workSpaceService.getDishOverView());
    }



    /**
     * 工作台
     *      查询套餐总览
     */
    @ApiOperation(tags = {"工作台"}, value = "套餐总览", notes = "查询套餐总览")
    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> setmealOverView(){
        return Result.success(workSpaceService.setmealOverView());
    }


}
